package com.android.Bean;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.android.DBTools.ADUS;
import com.android.DBTools.DBConnection;
import com.android.ObjectBean.GardenDisplayObjectList;

import net.sf.json.JSONObject;

public class GardenDisplayBean {
	public String gardenDisplay() throws ClassNotFoundException, SQLException {
		String sql = "SELECT g.garDisID,g.garDisText,d.garDisPath,d.garDisType FROM gardendisplay AS g "
				+ "JOIN dispiclist AS d ON g.garDisID = d.garDisID;";
		ResultSet rs = ADUS.selectData(sql);
		int count = 0;
		GardenDisplayObjectList gList = new GardenDisplayObjectList();
		rs.last();
		String[] picPath = new String[rs.getRow()];
		rs.beforeFirst();
		while (rs.next()) {
			if (count == 0) {
				gList.setGarDisID(rs.getString(rs.findColumn("garDisID")));
				gList.setGarDisText(rs.getString(rs.findColumn("garDisText")));
				gList.setGarDisType(rs.getString(rs.findColumn("garDisType")));
			}
			picPath[count++] = rs.getString(rs.findColumn("garDisPath"));
		}
		gList.setGarDisPath(picPath);
		DBConnection.closeCon();
		JSONObject json =JSONObject.fromObject(gList);
		return json.toString();

	}
}
